/**
 * This file is part of Lineage II Client Data Parser.
 * 
 * Lineage II Client Data Parser is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * Lineage II Client Data Parser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with Lineage II Client Data Parser.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.l2emuproject.parser.base;

import java.lang.IllegalAccessException;

import net.l2emuproject.io.SafelyPackedFile;

/**
 * @author Savormix
 *
 */
public interface IParser
{
	/** @return files needed to parse successfully */
	public String[] getNeededFiles();

	/** @return how many files are needed to parse successfully */
	public int getNeededFileCount();

	/** @return X, when 'Finished parsing X data.' */
	public String getParseType();

	/**
	 * Generate an array that specifies file parsing order.
	 * Necessary in order to ensure parsing consistency.
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void arrangeFiles() throws IllegalAccessException;

	/**
	 * Is this instance only a validator, or a fully-qualified one.
	 * @return are capabilities limited
	 */
	public boolean isValidator();

	/**
	 * Validates if a file can be correctly parsed using this parser.
	 * @param spf File contents as a SafelyPackedFile
	 * @return whether file is valid or not
	 */
	public boolean validate(SafelyPackedFile spf);

	/**
	 * Read the data stored in client files to memory.
	 * Generate class instances for each entry and set the basic values.
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void readClientData() throws IllegalAccessException;

	/**
	 * Analyze the generated instance attributes and set advanced values.
	 * Sort class instances by ID.
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void selfAdvancedAnalysis() throws IllegalAccessException;

	/**
	 * Write data from memory to a file ready to use by a l2j-based server emulator.
	 * Should be done asynchronously. May do nothing.
	 * @param chronicle Chronicle ID
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void writeServerData(int chronicle) throws IllegalAccessException;

	/**
	 * Generate a basic *.properties file from gathered and analyzed data.
	 * Should be done asynchronously.
	 * The file is generated to be further analyzed by humans ;)
	 * @param chronicle Chronicle ID
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void writeSimpleData(int chronicle) throws IllegalAccessException;

	/**
	 * Quit the application.
	 * @throws IllegalAccessException when invoked on a validate-only parser
	 */
	public void asyncWriteFinalizer() throws IllegalAccessException;
}
